home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Development Tools & Languages / Dylan Related / Mindy / Mindy 1.2 - portable sources / doc / print.txt < prev    next >
Encoding:
Text File  |  1995-03-15  |  16.3 KB  |  380 lines  |  [TEXT/ttxt]

  1. [NOTE: This file has been generated by a series of translation tools that
  2.  converted an original FrameMaker .mif file to this .txt file.  The
  3.  conversion tools created the table of contents and uppercased all
  4.  identifiers.  The printed representation of all identifiers in this
  5.  interface is lowercase.  The conversion tools also sometimes drops hyphens
  6.  from identifiers, so if you think a name should have a hyphen in it, it
  7.  probably does.  It is not worth the effort to manually fix this .txt file
  8.  to correct these problems.]
  9.  
  10.  
  11.                            GWYDION PRINT FOR DYLAN
  12.                            =======================
  13.  
  14. Designed by the Gwydion Project
  15.  
  16. Version 1.0 :
  17.  
  18. ------------------------------------------------------------------------------
  19.  
  20. Table of Contents
  21. -----------------
  22.  
  23. 1.  Print Functions
  24.  
  25. 2.  Print Request Inspection Functions
  26.  
  27. 3.  Pretty Printing
  28.  
  29. ------------------------------------------------------------------------------
  30.  
  31. This document describes the Print library designed by the Gwydion Project at
  32. Carnegie Mellon University. This library provides an interface that outputs
  33. an object in Dylan literal syntax if the object can be represented as a
  34. Dylan literal, and otherwise, outputs the object in an
  35. implementation-dependent manner. There are essentially two functions, print
  36. and printobject. The print function accepts keyword arguments that form a
  37. print request, controlling features such as circular printing, how deep
  38. within a data structure to print, how many elements in long sequences to
  39. print before using an ellipsis notation, whether pretty printing is desired,
  40. and so on. Users extend print's ability to print various objects by adding
  41. methods to the print-object function. The print function handles most of the
  42. overhead to satisfy special print requests, outputting any special notations
  43. required, and it only calls print-object when it is necessary to print
  44. objects. Users should always call the print function to output objects,
  45. especially recursively from within print-object methods to output an
  46. object's components. Users should never call print-object directly.
  47.  
  48. The Print library exports two modules, Print and Pprint. The Gwydion
  49. implementation of this library requires the Gwydion Streams library.
  50.  
  51. 1.  Print Functions
  52. -------------------
  53. The Print module offers two functions for users to call to print objects,
  54. print and print-to-string.
  55.  
  56. *default-level*  [Variable]
  57.  
  58. *default-length*  [Variable]
  59.  
  60. *default-circle?*  [Variable]
  61.  
  62. *default-pretty?*  [Variable]
  63.  
  64.         These variables provide default values for calls to the print
  65.         function. Their values are implementation-dependent.
  66.  
  67. print  [Function]
  68.  
  69.     Arguments
  70.         object :: <object>
  71.         stream :: <stream>
  72.         #key level :: false-or(<fixed-integer>) = *default-level*,
  73.         length :: false-or(<fixed-integer>) = *default-level*,
  74.         circle? :: <boolean> = *default-circle?*,
  75.         pretty? :: <boolean> = *default-pretty?*
  76.     Values
  77.         none
  78.     Description
  79.         Prints object to stream according to the print request formed by the
  80.         keyed arguments. A first call to print creates a printing stream to
  81.         represent the print request, and recursive calls to print on this
  82.         printing stream process the keyed arguments differently (see below).
  83.         There are inspection functions for querying the print request (see
  84.         Section Print Request Inspection Functions). When print actually
  85.         prints an object, it calls print-object. Though the inspection
  86.         functions for querying the print request allow you to inspect any
  87.         parameter of the print request, print-object methods should only
  88.         need to call print-length. All other aspects of the print request
  89.         are handled by print. There is one exception which is described in
  90.         Section Pretty Printing.
  91.  
  92.         Level controls how deep into a nested data structure to print. The
  93.         value #f indicates that there is no limit. The default,
  94.         *default-level*, has no effect on recursive calls to print.
  95.         Recursive calls to print may change the value of print-level
  96.         explicitly, but print always uses a value to ensure the print
  97.         request formed by the first call to print is never exceeded. For
  98.         example, if a first call to print set the level to 5, and while at a
  99.         depth of 3, a recursive call specified a level of 4, the recursive
  100.         call would only descend 2 more levels, not 4.
  101.  
  102.         Length controls how many elements of a sequence to print before
  103.         printing ellipsis notation (...). The value #f indicates that there
  104.         is no limit. The printlength control can be interpreted loosely by
  105.         some print-object methods to control how many elements of any kind
  106.         of object to print; for example, the default <object> method might
  107.         regard print-length to determine how many slot-name/value pairs to
  108.         print. The default, *default-length*, has no effect on recursive
  109.         calls to print. Recursive calls to print may change the value of
  110.         print-length explicitly, but they may only decrease the value, never
  111.         increase it.
  112.  
  113.         Circle? indicates whether printing should check all subcomponent
  114.         references to make sure the printing process does not infinitely
  115.         recurse through a data structure. Circular printing also tags
  116.         objects that occur more than once when they are first printed, and
  117.         later occurrences are printed as a reference to the previously
  118.         emitted tag. The default, *default-circle?*, has no effect on
  119.         recursive calls to print. If print-circle? is already #t, then it
  120.         remains #t throughout all recursive calls. If print-circle? is #f,
  121.         then recursive calls to print can change the value to #t; however,
  122.         when printing exits the dynamic scope of the call that changed the
  123.         value to #t, the value reverts back to #f. If the original call to
  124.         print specifies circle? as #f, and dynamically distinct recursive
  125.         calls turn circular printing on and off, all output generated while
  126.         circular printing was on shares the same tagging space; that is, if
  127.         #1# is printed twice, once from each of two distinct recursive calls
  128.         to print, then each #1# is guaranteed to signify the same \==
  129.         object.
  130.  
  131.         Pretty? indicates whether printing should attempt to insert line
  132.         breaks and indentation to format objects according to how
  133.         programmers tend to find it easier to read data. The default,
  134.         *default-pretty?*, has no effect on recursive calls to print. If
  135.         print-pretty? is already #t, then it remains #t throughout all
  136.         recursive calls. If printpretty? is #f, then recursive calls to
  137.         print can change the value to #t; however, when printing exits the
  138.         dynamic scope of the call that changed the value to #t, the value
  139.         reverts back to #f.
  140.  
  141. print-to-string  [Function]
  142.  
  143.     Arguments
  144.         object :: <object>
  145.         #key level :: false-or(<fixed-integer>) = *default-level*,
  146.         length :: false-or(<fixed-integer>) = *default-level*,
  147.         circle? :: <boolean> = *default-circle?*,
  148.         pretty? :: <boolean> = *default-pretty?*
  149.     Values
  150.         result :: <byte-string>
  151.     Description
  152.         Calls print to produce output according to the print request formed
  153.         by the keyed arguments and returns the output as a string.
  154.  
  155. print-object  [Generic Function]
  156.  
  157.     Arguments
  158.         object :: <object>
  159.         stream :: <stream>
  160.     Values
  161.         none
  162.     Description
  163.         Users extend print's ability to print various objects by adding
  164.         methods to the print-object function. When print actually prints an
  165.         object, it calls print-object. Users should never call print-object
  166.         directly.
  167.  
  168. 2.  Print Request Inspection Functions
  169. --------------------------------------
  170. The Print module exports the following functions for querying the print
  171. request and current print state:
  172.  
  173. print-length  [Function]
  174.  
  175.     Arguments
  176.         stream :: <stream>
  177.     Values
  178.         length :: false-or(<fixed-integer>)
  179.     Description
  180.         Returns the current value for the print request. See the print
  181.         function for details.
  182.  
  183. print-level  [Function]
  184.  
  185.     Arguments
  186.         stream :: <stream>
  187.     Values
  188.         level :: false-or(<fixed-integer>)
  189.     Description
  190.         Returns the current value for the print request. See the print
  191.         function for details. Users should have little use for this function
  192.         because print takes care to call print-object only when the print
  193.         level has not been exhausted.
  194.  
  195. print-depth  [Function]
  196.  
  197.     Arguments
  198.         stream :: <stream>
  199.     Values
  200.         depth :: false-or(<fixed-integer>)
  201.     Description
  202.         Returns the current depth to which printing has descended into the
  203.         object on which print was originally called. Users should have
  204.         little use for this function because print takes care to call
  205.         print-object only when the print level has not been exhausted.
  206.  
  207. print-circle?  [Function]
  208.  
  209.     Arguments
  210.         stream :: <stream>
  211.     Values
  212.         circle? :: <boolean>
  213.     Description
  214.         Returns whether circular printing is on. Users should have little
  215.         use for this function because print takes care to detect
  216.         circularities, tag multiply referenced objects, and emit tags rather
  217.         than descending into objects to repeatedly print them.
  218.  
  219. print-pretty?  [Function]
  220.  
  221.     Arguments
  222.         stream :: <stream>
  223.     Values
  224.         pretty? :: <boolean>
  225.     Description
  226.         Returns whether pretty printing is on. Users should have little use
  227.         for this function (see Section Pretty Printing).
  228.  
  229. 3.  Pretty Printing
  230. -------------------
  231. The Print library implements most of the pretty printing technology
  232. described by Richard C. Waters in Common Lisp The Language, second edition.
  233. The interface is slightly different because Dylan does not currently have
  234. macros. This section only summarizes the pretty printing functionality to
  235. provide a quick reference for users of the Print library, and readers should
  236. refer to the Common Lisp manual for more details.
  237.  
  238. When writing print-object methods, users can ignore whether pretty printing
  239. is in effect. If you write your print-object method using pretty printing
  240. functions, then when pretty printing is in effect, the output will be pretty
  241. printed. When pretty printing is not in effect, your method will produce
  242. output as though you had not written it to use pretty printing. All
  243. printobject methods that are written to do pretty printing must call the
  244. pretty printing functions within the dynamic scope of a call to
  245. pprint-logical-block; otherwise, the pretty printing functions are no-ops.
  246.  
  247. The Pprint module exports the following variables:
  248.  
  249. *default-line-length*  [Variable]
  250.  
  251.         This is the line length used by the pretty printer to determine how
  252.         much output will fit on a single line. The value must be an
  253.         <integer>, and it defaults to 80.
  254.  
  255. *print-miser-width*  [Variable]
  256.  
  257.         This variable controls miser mode. Whenever a logical block (see
  258.         pprint-logical-block) begins in a column of output that is greater
  259.         than *default-line-length* - *print-miser-width*, then pretty
  260.         printing is in miser mode. The value must be an integer or #f (the
  261.         default). #f indicates that the pretty printer should never enter
  262.         miser mode.
  263.  
  264. pprint-logical-block  [Function]
  265.  
  266.     Arguments
  267.         stream :: <stream>
  268.         #key prefix :: false-or(<byte-string>)
  269.         per-line-prefix :: false-or(<byte-string>)
  270.         body :: <function>
  271.         suffix :: false-or(<byte-string>)
  272.         column :: limited(<fixed-integer>, min: 0)
  273.     Values
  274.         none
  275.     Description
  276.         This function groups printing into a logical block. The logical
  277.         block provides boundaries for new levels of indentation, affects
  278.         #"linear" newlines, and so on. Prefix is a string to print at the
  279.         beginning of the logical block. The blocks indentation is
  280.         automatically set to be one character position greater than the
  281.         column in which prefix ends. Alternatively, per-line-prefix is a
  282.         string to print on every line of the logical block. This function
  283.         signals an error if it is called with both prefix and
  284.         per-line-prefix supplied as non-#f. Suffix is a string to print at
  285.         the end of the logical block. Column advises the pretty printer as
  286.         to the current column of the output stream (defaults to zero). The
  287.         column argument may be ignored entirely by some methods, and it may
  288.         be ignored in some cases by methods that can better determine the
  289.         stream's current output column.
  290.  
  291.         Body must be a function that can take one argument, and this
  292.         argument is a stream. The body function should use the stream
  293.         argument passed to it; the body function should not close over the
  294.         stream argument to pprintlogicalblock. Pprint-logical-block wraps
  295.         stream with a pretty printing stream when stream is any other kind
  296.         of stream. If stream is already a pretty printing stream, then the
  297.         body function is called on stream.
  298.  
  299.         All printobject methods that are written to do pretty printing must
  300.         call the other pretty printing functions within the dynamic scope of
  301.         a call to pprint-logical-block; otherwise, the pretty printing
  302.         functions are no-ops.
  303.  
  304. pprint-newline  [Function]
  305.  
  306.     Arguments
  307.         kind :: one-of(#"fill", #"linear", #"miser", #"mandatory")
  308.         stream :: <stream>
  309.     Values
  310.         none
  311.     Description
  312.         This function announces a conditional newline to the pretty printer.
  313.         The pretty printer emits a newline depending on the kind and the
  314.         state of the pretty printer's current line buffer. The kind argument
  315.         has roughly the following meanings:
  316.  
  317.         #"fill"
  318.             Emit a newline if the current section of output does not fit on
  319.             one line.
  320.         #"linear"
  321.             Emit a newline if any #"linear" newline in the current section
  322.             needs to be emitted. That is, if a current section of output
  323.             cannot fit on one line, and any one of the #"linear" newlines in
  324.             the section needs to be emitted, then emit them all.
  325.         #"miser"
  326.             Emit a newline as if it were a #"linear" newline, but only when
  327.             miser mode is in effect. Miser style is in effect when a logical
  328.             block starts past a particular column of output.
  329.         #"mandatory"
  330.             Emit a newline always. Establish that any containing sections
  331.             cannot be printed on a single line so that #"linear" and
  332.             #"miser" newlines will be emitted as appropriate.
  333.  
  334. pprint-indent  [Function]
  335.  
  336.     Arguments
  337.         relative-to :: one-of(#"block", #"current")
  338.         n :: <fixed-integer>
  339.         stream :: <stream>
  340.     Values
  341.         none
  342.     Description
  343.         This function specifies the indentation to use within the current
  344.         logical block. When relative-to is #"block", then pprint-indent sets
  345.         the indentation to the column of the first character of the logical
  346.         block plus n. When relative-to is #"current", then pprint-indent
  347.         sets the indentation to the current column plus n.
  348.  
  349. pprint-tab  [Function]
  350.  
  351.     Arguments
  352.         kind :: one-of(#"line", #"line-relative", #"section",
  353.         #"section-relative")
  354.         colnum :: <fixed-integer>
  355.         colinc :: <fixed-integer>
  356.         stream :: <stream>
  357.     Values
  358.         none
  359.     Description
  360.         This function announces a tab to the pretty printer. Colnum and
  361.         colinc have meaning based on the value of kind:
  362.  
  363.         #"line"
  364.             Tab to output column colnum. If the output is already at or
  365.             beyond colnum, then add colinc to colnum until printing can
  366.             continue at a column beyond the end of the output already on the
  367.             line.
  368.         #"line-relative"
  369.             Output colnum spaces. Then output enough spaces to tab to a
  370.             column that is a multiple of colinc from the beginning of the
  371.             line.
  372.         #"section"
  373.             This is similar to #"line", but column counting is relative to
  374.             the beginning of the current section rather than the beginning
  375.             of the line.
  376.         #"section-relative"
  377.             This is similar to #"line-relative", but column counting is
  378.             relative to the beginning of the current section rather than the
  379.             beginning of the line.
  380.